<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="${pageContext.request.contextPath}/media/layui/css/layui.css" media="all">
<script type="text/javascript" src="${pageContext.request.contextPath}/media/js/jquery.min.js"></script>
</head>
<body>
	<div class="layui-container" style="margin-top: 5px">
		<form class="layui-form" action="gradeadd.do" method="post">
			<div class="layui-form-item">
				<label class="layui-form-label">原始密码</label>
				<div class="layui-input-block">
					<input type="password" name="oldpass" lay-verify="name" autocomplete="off"
						placeholder="请输入密码" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码</label>
				<div class="layui-input-block">
				 <input type="password" name="password1" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认新密码</label>
				
				<div class="layui-input-block">
			      <input type="password" name="password2" class="layui-input" >
				</div>
			</div>
			<div class="layui-form-item">
				<input class="layui-btn"  style="margin-left: 10%" type="button" value="确认修改" onclick="duibi()">
				
			</div>
		</form>
	</div>


	<script src="${pageContext.request.contextPath}/media/layui/layui.js"></script>
	<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
	<script>
	var form;
		layui.use([ 'form', 'laydate' ],
				function() {
				form = layui.form, layer = layui.layer, laydate = layui.laydate;
						//日期
						laydate.render({
							elem : '#date'
						});
						initData();
		});
		
		function xinjiu() {
			var p1 = $("[name=password1]").val();
			var p2 = $("[name=password2]").val();
			if(p1!=p2){
				alert("两次密码不一致");
			}
		}
		
		//判断
		function oppan() {
			var op = $("[name=oldpass]").val();//输入的旧密码
			if(op.length==0){
				alert("请输入旧密码");
			}
		}
		function p1pan() {
			var p1 = $("[name=password1]").val();//第一次密码
			if(p1.length==0){
				alert("请输入新密码");
			}
		}
		
		function p2pan() {
			var p1 = $("[name=password1]").val();//第一次密码
			var p2 = $("[name=password2]").val();//第二次密码
			if(p2.length!=0){
				if(p1!=p2){
				alert("两次密码不一致");
				}
			}else{
				alert("请确认密码");
			}
		}
		
		//
		
		
		function duibi() {
			//进行对比
			var p1 = $("[name=password1]").val();//第一次密码
			var p2 = $("[name=password2]").val();//第二次密码
			var op = $("[name=oldpass]").val();//输入的旧密码
			var rp = ${sessionScope.user.password}//正确的旧密码
			var uid = ${sessionScope.user.id}//用户的ID 用来到后台进行密码的更新
			if(op.length==0){
				alert("请输入旧密码");
			}else{
				if(p1.length==0){
					alert("请输入新密码");
				}else{
					if(p2.length==0){
						alert("请确认新密码");
					}else{
						if(p1!=p2){
							alert("两次密码不一致");
						}else{
							if(op==rp){
								location.href="${pageContext.request.contextPath}/user/upmima?uid="+uid+"&nmima="+p1;
							}else{
								alert("输入的密码有误 请重新输入");
							}
						}
					}
				}
			}
		}
		
	</script>
</body>
</html>